home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Environments / AppMkr151#2 / Libraries / MPW / AMLibraryC / DialogAids.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-27  |  15.8 KB  |  677 lines  |  [TEXT/MPS ]

  1. /* © 1988-91, Bowers Development Corp. */
  2. /* DialogAids.c */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Desk.h>                /* for SystemTask */
  8. #include <Dialogs.h>
  9. #include <Events.h>
  10. #include <Lists.h>
  11. #include <Menus.h>
  12. #include <TextEdit.h>
  13.  
  14. #include "EventLoop.h"
  15. #include "Globals.h"
  16. #include "ResourceDefs.h"
  17. #include "WindowAids.h"
  18. #include "Windowing.h"
  19. #include "DoScrap.h"
  20.  
  21. #include "DialogAids.h"
  22.  
  23. #include <OSUtils.h>
  24. #include <Packages.h>
  25. #include <ToolUtils.h>
  26. #include "Cursors.h"    /* cursorRgn for WaitNextEvent */
  27.  
  28. #pragma segment DialogAids
  29.  
  30. /*----------*/
  31. Rect    GetDRect    (short        itemNr)
  32. {
  33.     short        itemType;
  34.     Handle        itemHandle;
  35.     Rect        itemRect;
  36.  
  37.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  38.  
  39.     return (itemRect);
  40. } /*GetDRect*/
  41.  
  42. /*----------*/
  43. static Handle    GetItemHandle    (short        itemNr);
  44. static Handle    GetItemHandle    (short        itemNr)
  45. {
  46.     short        itemType;
  47.     Handle        itemHandle;
  48.     Rect        itemRect;
  49.  
  50.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  51.  
  52.     return (itemHandle);
  53. } /*GetItemHandle*/
  54.  
  55. /*----------*/
  56. pascal void LineItem    (DialogPtr        dialog,
  57.                          short            itemNr)
  58. {
  59. #pragma unused (dialog)
  60.  
  61.     PenState        savePen;
  62.     Rect            itemRect;
  63.  
  64.     GetPenState (&savePen);
  65.     PenNormal ();
  66.     PenPat (&qd.gray);
  67.     itemRect = GetDRect (itemNr);
  68.     MoveTo (itemRect.left, itemRect.top);
  69.     LineTo (itemRect.right - 1, itemRect.bottom - 1);
  70.     SetPenState (&savePen);
  71. } /*LineItem*/
  72.  
  73. /*----------*/
  74. pascal void RectItem    (DialogPtr        dialog,
  75.                          short            itemNr)
  76. {
  77. #pragma unused (dialog)
  78.  
  79.     Rect            itemRect;
  80.     PenState        savePen;
  81.  
  82.     GetPenState (&savePen);
  83.     PenNormal ();
  84.     itemRect = GetDRect (itemNr);
  85.     FrameRect (&itemRect);
  86.     SetPenState (&savePen);
  87. } /*RectItem*/
  88.  
  89. /*----------*/
  90. void SetUserItem    (short        itemNr,
  91.                      ProcPtr    doDraw)
  92. {
  93.     short            itemType;
  94.     Handle            itemHandle;
  95.     Rect            itemRect;
  96.  
  97.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  98.     SetDItem (qd.thePort, itemNr, itemType, (Handle) doDraw, &itemRect);
  99. } /*SetUserItem*/
  100.  
  101. /*----------*/
  102. void OutlineButton    (short        itemNr)
  103. {
  104.     Rect            itemRect;
  105.     PenState        savePen;
  106.  
  107.     GetPenState (&savePen);
  108.     PenNormal ();
  109.     PenSize (3, 3);
  110.     itemRect = GetDRect (itemNr);
  111.     InsetRect (&itemRect, -4, -4);
  112.     FrameRoundRect (&itemRect, 16, 16);
  113.     SetPenState (&savePen);
  114. } /*OutlineButton*/
  115.  
  116. /*----------*/
  117. void EnableDItem    (short        itemNr,
  118.                      Boolean    enable)
  119. {
  120.     short            itemType;
  121.     Handle            itemHandle;
  122.     Rect            itemRect;
  123.     ControlHandle    control;
  124.  
  125.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  126.     if (enable) {
  127.         itemType &= ~itemDisable;
  128.     } else {
  129.         itemType |= itemDisable;
  130.     }
  131.     SetDItem (qd.thePort, itemNr, itemType, itemHandle, &itemRect);
  132.  
  133.     if ((itemType & ctrlItem) != 0) {        /* it's a control */
  134.         control = (ControlHandle) itemHandle;
  135.         HiliteScroll (control, enable);
  136.     } /*else … do nothing?*/
  137. } /*EnableDItem*/
  138.  
  139. /*----------*/
  140. void SetDText        (short        itemNr,
  141.                      Str255        text)
  142. {
  143.     Handle            itemHandle;
  144.  
  145.     itemHandle = GetItemHandle (itemNr);
  146.     SetIText (itemHandle, text);
  147. } /*SetDText*/
  148.  
  149. /*----------*/
  150. void GetDText        (short        itemNr,
  151.                      Str255        text)
  152. {
  153.     Handle            itemHandle;
  154.  
  155.     itemHandle = GetItemHandle (itemNr);
  156.     GetIText (itemHandle, text);
  157. } /*GetDText*/
  158.  
  159. /*----------*/
  160. void SetDNum        (short        itemNr,
  161.                      long        num)
  162. {
  163.     Str255            text;
  164.  
  165.     NumToString (num, text);
  166.     SetDText (itemNr, text);
  167. } /*SetDNum*/
  168.  
  169. /*----------*/
  170. void GetDNum        (short        itemNr,
  171.                      long        *num)
  172. {
  173.     Str255            text;
  174.  
  175.     GetDText (itemNr, text);
  176.     StringToNum (text, num);
  177. } /*GetDNum*/
  178.  
  179. /*----------*/
  180. void SetCheckbox    (short        itemNr,
  181.                      Boolean    checked)
  182. {
  183.     ControlHandle    control;
  184.  
  185.     control = (ControlHandle) GetItemHandle (itemNr);
  186.     SetCtlMax (control, 1);
  187.     SetCtlValue (control, checked);
  188. } /*SetCheckbox*/
  189.  
  190. /*----------*/
  191. void DoCheckbox        (short        itemNr,
  192.                      Boolean    *checked)
  193. {
  194.     *checked = !*checked;
  195.     SetCheckbox (itemNr, *checked);
  196. } /*DoCheckbox*/
  197.  
  198. /*----------*/
  199. void SetRadio        (short        firstItem,
  200.                      short        choice)
  201. {
  202.     SetCheckbox (firstItem + (choice - 1), true); 
  203. } /*SetRadio*/
  204.  
  205. /*----------*/
  206. void DoRadio        (short        firstItem,
  207.                      short        itemNr,
  208.                      short        *choice)
  209. {
  210.     SetCheckbox (firstItem + (*choice - 1), false);
  211.     *choice = itemNr - firstItem + 1;
  212.     SetCheckbox (firstItem + (*choice - 1), true); 
  213. } /*DoRadio*/
  214.  
  215. /*----------*/
  216. void InvertIcon        (short        itemNr);
  217. void InvertIcon        (short        itemNr)
  218. {
  219.     Rect            itemRect;
  220.  
  221.     itemRect = GetDRect (itemNr);
  222.     InsetRect (&itemRect, 1, 1);
  223.     InvertRect (&itemRect);
  224. } /*InvertIcon*/
  225.  
  226. /*----------*/
  227. void DoIconRadio    (short        firstIcon,
  228.                      short        itemNr,
  229.                      short        *choice)
  230. {
  231.     InvertIcon (firstIcon + (*choice - 1));
  232.     *choice = (itemNr - firstIcon) + 1;
  233.     InvertIcon (firstIcon + (*choice - 1));
  234. } /*DoIconRadio*/
  235.  
  236. /*----------*/
  237. void SetCtlChoice    (short        itemNr,
  238.                      short        choice)
  239. {
  240.     ControlHandle    control;
  241.  
  242.     control = (ControlHandle) GetItemHandle (itemNr);
  243.     SetCtlValue (control, choice);
  244. } /*SetCtlChoice*/
  245.  
  246. /*----------*/
  247. short GetCtlChoice    (short        itemNr)
  248. {
  249.     ControlHandle    control;
  250.  
  251.     control = (ControlHandle) GetItemHandle (itemNr);
  252.     return (GetCtlValue (control));
  253. } /*GetCtlChoice*/
  254.  
  255. /*----------*/
  256. void DoPalette        (short        itemNr,
  257.                      short        *choice)
  258. {
  259.     *choice = GetCtlChoice (itemNr);
  260. } /*DoPalette*/
  261.  
  262. /*----------*/
  263. void DoMultiState    (short         itemNr,
  264.                      short        *value)
  265. {
  266.     ControlHandle    control;
  267.  
  268.     control = (ControlHandle) GetItemHandle (itemNr);
  269.     if (*value == GetCtlMax (control)) {
  270.         *value = GetCtlMin (control);
  271.     } else {
  272.         *value += 1;
  273.     }
  274.     SetCtlValue (control, *value);
  275. } /*DoMultiState*/
  276.  
  277. /*----------*/
  278. void SetScrollItem  (short        itemNr,
  279.                      short        value,
  280.                      short        min,
  281.                      short        max,
  282.                      short        pageSize)
  283. {
  284.     ControlHandle    scroll;
  285.  
  286.     scroll = (ControlHandle) GetItemHandle (itemNr);
  287.     SetCtlMin     (scroll, min);
  288.     SetCtlMax     (scroll, max);
  289.     SetCtlValue     (scroll, value);
  290.     SetCRefCon     (scroll, pageSize);
  291.     HiliteScroll (scroll, (min < max));
  292. } /*SetScrollItem*/
  293.  
  294. /*----------*/
  295. void DoScrollItem    (short        itemNr,
  296.                      short        *value)
  297. {
  298.     ControlHandle    scroll;
  299.  
  300.     scroll = (ControlHandle) GetItemHandle (itemNr);
  301.     *value = GetCtlValue (scroll);
  302. } /*DoScrollItem*/
  303.  
  304. /*----------*/
  305. void DrawPopup        (short        itemNr,
  306.                      short        menuID,
  307.                      short        choice)
  308. {
  309.     Rect            itemRect;
  310.  
  311.     itemRect = GetDRect (itemNr);
  312.     UpdatePopup (itemRect, menuID, choice);
  313. } /*DrawPopup*/
  314.  
  315. /*----------*/
  316. void DoPopup        (short        itemNr,
  317.                      short        menuID,
  318.                      short        *choice)
  319. {
  320.     Rect            itemRect;
  321.  
  322.     itemRect = GetDRect (itemNr);
  323.     TrackPopup (itemRect, menuID, choice);
  324. } /*DoPopup*/
  325.  
  326. /*----------*/
  327. void InvertLabel    (short        itemNr)
  328. {
  329.     Rect            itemRect;
  330.  
  331.     itemRect = GetDRect (itemNr);
  332.     InvertRect (&itemRect);
  333. } /*InvertLabel*/
  334.  
  335. /*----------*/
  336. ListHandle  Vert1List    (short        itemNr)
  337. {
  338.     Rect            itemRect;
  339.     ListHandle        list;
  340.  
  341.     itemRect = GetDRect (itemNr);
  342.     list = NewV1List (itemRect, qd.thePort);
  343.  
  344.     return (list);
  345. } /*Vert1List*/
  346.  
  347. /*----------*/
  348. Boolean FilterList    (EventRecord    *event,
  349.                      ListHandle        list,
  350.                      short            listItem,
  351.                      short            dblClickItem,
  352.                      short            *itemHit)
  353. {
  354.     Boolean            filtered;
  355.     Point            mousePos;
  356.  
  357.     filtered = false;
  358.     if ((*event).what == mouseDown) {
  359.         mousePos = (*event).where;
  360.         GlobalToLocal (&mousePos);
  361.         if (FindDItem (qd.thePort, mousePos) + 1 == listItem) {
  362.             if (LClick (mousePos, (*event).modifiers, list)) {
  363.                 *itemHit = dblClickItem;
  364.             } else {
  365.                 *itemHit = listItem;
  366.             }
  367.             filtered = true;
  368.         }
  369.     }
  370.     return (filtered);
  371. } /*FilterList*/
  372.  
  373. /*----------*/
  374. Boolean FilterScroll    (EventRecord    *event,
  375.                          short            scrollItem,
  376.                          ScrollProcPtr    actionProc,
  377.                          short            *itemHit)
  378. {
  379.     Boolean            filtered;
  380.     Point            mousePos;
  381.     short            partCode;
  382.     ControlHandle    whichControl;
  383.  
  384.     filtered = false;
  385.     if ((*event).what == mouseDown) {
  386.         mousePos = (*event).where;
  387.         GlobalToLocal (&mousePos);
  388.         if (FindDItem (qd.thePort, mousePos) + 1 == scrollItem) {
  389.             partCode = FindControl (mousePos, qd.thePort, &whichControl);
  390.             if (partCode != 0) {
  391.                 TrackScroll (whichControl, partCode, mousePos, actionProc);
  392.                 *itemHit = scrollItem;
  393.                 filtered = true;
  394.             }
  395.         }
  396.     }
  397.     return (filtered);
  398. } /*FilterScroll*/
  399.  
  400. /*----------*/
  401. void FilterIcon        (EventRecord    *event,
  402.                      short            firstIcon,
  403.                      short            choice)
  404. {
  405.     short            itemType;
  406.     Handle            itemHandle;
  407.     Rect            itemRect;
  408.  
  409.     if (((*event).what == updateEvt)
  410.     &&  ((WindowPtr) (*event).message == qd.thePort)) {
  411.         GetDItem (qd.thePort, firstIcon + (choice - 1), &itemType, &itemHandle, &itemRect);
  412.         PlotIcon (&itemRect, itemHandle);
  413.         ValidRect (&itemRect);
  414.         InsetRect (&itemRect, 1, 1);
  415.         InvertRect (&itemRect);
  416.     }
  417. } /*FilterIcon*/
  418.  
  419. /*----------*/
  420. pascal Boolean StandardFilter    (DialogPtr        whichDialog,
  421.                                  EventRecord    *event,
  422.                                  short            *itemHit)
  423. {
  424.     #define returnKey        13
  425.     #define enter            3
  426.     #define esc                27
  427.     #define pushButton        (ctrlItem + btnCtrl)
  428.     
  429.     Boolean            filtered;
  430.     DialogPeek        whichPeek;
  431.     short            defItem;
  432.     char            key;
  433.     short            itemType;
  434.     Handle            itemHandle;
  435.     Rect            itemRect;
  436.     long            finalTicks;
  437.  
  438.     filtered = false;
  439.     whichPeek = (DialogPeek) whichDialog;
  440.     defItem = whichPeek->aDefItem;
  441.     switch ((*event).what) {
  442.     case keyDown:
  443.     case autoKey:
  444.         key = (*event).message & charCodeMask;
  445.         if ((key == returnKey) || (key == enter) || (key == esc)
  446.         || ((key == '.') && (((*event).modifiers & cmdKey) != 0))) {
  447.             if ((key == returnKey) || (key == enter)) {
  448.                 *itemHit = defItem;
  449.             } else {
  450.                 *itemHit = cancel;
  451.             }
  452.             GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  453.             if ((itemType & itemDisable) == 0) {
  454.                 if ((itemType & (255 - itemDisable)) == pushButton) {
  455.                     HiliteControl ((ControlHandle) itemHandle, inButton);
  456.                     Delay (8, &finalTicks);
  457.                     HiliteControl ((ControlHandle) itemHandle, 0);
  458.                 }
  459.                 filtered = true;
  460.             } /*if*/
  461.         } else {
  462.             if ((((*event).modifiers & cmdKey) != 0)
  463.             &&  ((key == 'x') || (key == 'c') || (key == 'v'))) {
  464.                 *itemHit = (whichPeek)->editField + 1;
  465.                 switch (key) {
  466.                 case 'x':
  467.                         DlgCut (whichDialog);
  468.                         scrapDirty = (*itemHit > 0);
  469.                     break;
  470.                 case 'c':
  471.                         DlgCopy (whichDialog);
  472.                         scrapDirty = (*itemHit > 0);
  473.                         *itemHit = 0;
  474.                     break;
  475.                 case 'v':
  476.                         DlgPaste (whichDialog);
  477.                     break;
  478.                 } /*switch*/
  479.                 if (*itemHit > 0) {
  480.                     GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  481.                     if ((itemType & itemDisable) == 0) {
  482.                         filtered = true;
  483.                     }
  484.                 }
  485.                 if (!filtered) {
  486.                     (*event).what = nullEvent;
  487.                 }
  488.             }
  489.         }
  490.         break;
  491.     case updateEvt:
  492.         if ((WindowPtr) (*event).message == qd.thePort) {
  493.             GetDItem (whichDialog, defItem, &itemType, &itemHandle, &itemRect);
  494.             if ((itemType & (255 - itemDisable)) == pushButton) {
  495.                 OutlineButton (defItem);
  496.             }
  497.         } else if (!IsDialogEvent (event)) {
  498.             curEvent = *event;
  499.             DoUpdate ();    /* update other windows */
  500.         }
  501.         break;
  502.     } /*switch*/
  503.     return (filtered);
  504. } /*StandardFilter*/
  505.  
  506. /*----------*/
  507. /* This procedure handles mouseDown in a non-dialog window.    */
  508. /*----------*/
  509. static void    DoMouseDown (void);
  510. static void    DoMouseDown (void)
  511. {
  512.     long            menuChoice;
  513.     short            menuID;
  514.     short            itemNr;
  515.     WindowPtr        whichWindow;
  516.     short            whichPart;
  517.  
  518.     whichPart = FindWindow (curEvent.where, &whichWindow);
  519.     switch (whichPart) {
  520.         case inMenuBar:
  521.                 menuChoice = MenuSelect (curEvent.where);
  522.                 menuID = HiWord (menuChoice);
  523.                 itemNr = LoWord (menuChoice);
  524.                 if ((menuID != 0) && (itemNr != 0)) {
  525. /*Need to handle Cut, Copy, Paste here just like StandardFilter doesnot*/
  526.                     SysBeep (1);
  527.                 }    /* otherwise, MenuSelect returned 0. Either the user    */
  528.                     /* chose nothing, or the user chose from a System        */
  529.                     /* menu, and it's been taken care of                    */
  530.             break;
  531.         case inDrag:
  532.                 if (whichWindow == FrontWindow ()) {
  533.                     DoDrag (whichWindow);            /*permit drag of this dialog*/
  534.                 } else {
  535.                     SysBeep (1);                    /*can't drag any other window*/
  536.                 }
  537.             break;
  538.         case inSysWindow:
  539.         case inContent:
  540.         case inDesk:
  541.         case inGrow:
  542.         case inGoAway:
  543.         case inZoomIn:
  544.         case inZoomOut:
  545.         default:
  546.                 SysBeep (1);
  547.             break;
  548.     } /*case*/
  549. } /*DoMouseDown*/
  550.  
  551. /*----------*/
  552. static Boolean        sFiltered;            /*used by DoModalEvent & MovableDialog*/
  553.  
  554. /*----------*/
  555. static Boolean GetEvent    (void);
  556. static Boolean GetEvent    ()
  557. {
  558.     Boolean            gotEvent;
  559.  
  560.     if (sysConfig.hasWNE) {
  561.         gotEvent = WaitNextEvent (everyEvent, &curEvent, 0L, cursorRgn);
  562.     } else {
  563.         SystemTask ();
  564.         gotEvent = GetNextEvent (everyEvent, &curEvent);
  565.     }
  566.     return (gotEvent);
  567. } /*GetEvent*/
  568.  
  569. /*----------*/
  570. /* This function processes the next modal dialog event and then returns. It is called        */
  571. /* by MovableDialog, but it can also be called directly. Assumes that the frontmost            */
  572. /* window is a modal (or movable modal) dialog window.                                        */
  573. /*                                                                                            */
  574. /* If the event is associated with an item in the current dialog, returns the item number.    */
  575. /* If filterProc (or System 7.0's standard filter, or DialogSelect) handled the event        */
  576. /* (and presumably set itemHit); sets sFiltered to true, otherwise sets sFiltered to false.    */
  577. /* If the event is not associated with an item in the current dialog, returns 0.            */
  578. /*----------*/
  579. short    DoModalEvent    (ModalFilterProcPtr        filterProc)
  580. {
  581.     WindowPtr        eventWindow;
  582.     short            itemHit;        /*function return value*/
  583.     GrafPtr            savePort;
  584.     DialogPtr        theDialog;
  585.  
  586.     GetPort(&savePort);
  587.  
  588.     sFiltered = false;
  589.     itemHit = 0;
  590.     theDialog = FrontWindow ();
  591.     if (GetEvent () || (curEvent.what == nullEvent)) {
  592.                                 /*got an event to process*/
  593.         if (curEvent.what == app4Evt) {
  594.           /* here so event won't get swallowed by IsDialogEvent */
  595.           /* and so suspend/resume can be translated to deactivate/activate */
  596.             DoApp4Event ();
  597.         }
  598.         if (IsDialogEvent (&curEvent)) {
  599.                                     /*it's a dialog event*/
  600.             if ((curEvent.what == activateEvt) || (curEvent.what == updateEvt)) {
  601.                 eventWindow = (DialogPtr) curEvent.message;
  602.             } else {
  603.                 eventWindow = FrontWindow ();
  604.             }
  605.             SetPort (eventWindow);
  606.             if (filterProc != NULL) {
  607.                                 /*caller passed a filterProc*/
  608.                 sFiltered = (*filterProc) (theDialog, &curEvent, &itemHit);
  609.             } else {
  610.                                 /*filterProc == NULL*/
  611. /* Need to do if (gestalt then if gestalt(stdfilter available)) sFiltered = stdfilternot    */
  612. /* See Tech Note #304 p. 4 for GetStdFilterProc                                                */
  613.                 sFiltered = StandardFilter (theDialog, &curEvent, &itemHit);
  614.             }
  615.             if (!sFiltered) {
  616.                     /*either filterProc == NULL, or filterProc
  617.                      didn't process curEvent (although filterProc
  618.                      may have altered curEvent)*/
  619. /*Don't need to handle Cmd-keys here, since StandardFilter does.*/
  620.                 sFiltered = DialogSelect (&curEvent, &theDialog, &itemHit);
  621.             } /*otherwise, sFiltered*/
  622.         } else {                /*it's not a dialog event*/
  623.             switch (curEvent.what) {
  624.                 case mouseDown:
  625.                         DoMouseDown ();
  626.                     break;
  627.                 case mouseUp:
  628.                 case keyDown:
  629.                 case autoKey:
  630.                                     /*do nothing*/
  631.                     break;
  632.                 case updateEvt:
  633.                         DoUpdate ();
  634.                     break;
  635.                 case activateEvt:
  636.                                     /*do nothing, to avoid setting cur to noCur*/
  637.                     break;
  638.                 case diskEvt:
  639.                         DoDiskEvent ();
  640.                     break;
  641.                 default:
  642.                         /*Do nothing*/
  643.                     break;
  644.             } /*case*/
  645.         } /*if dialog event or not*/
  646.     } /*otherwise, not GetEvent and curEvent.what != nullEvent*/
  647.  
  648.     SetPort(savePort);
  649.  
  650.     return (itemHit);
  651. } /*DoModalEvent*/
  652.  
  653. /*----------*/
  654. /* This procedure works just like ModalDialog, case plus:                            */
  655. /*    - clicking and dragging in the dialog's title bar will move the dialog            */
  656. /*    - application windows update                                                    */
  657. /*    - under System 7.0, uses the same standard filter proc as ModalDialog            */
  658. /* Under System 7.0, the dialog window's procID should be movableDBoxProc            */
  659. /* (== 5, from Windows.p).                                                            */
  660. /* Under System 6.x, procID movableDBoxProc is equivalent to dBoxProc, and the        */
  661. /* user won't be able to drag the dialog. However, if the procID is noGrowDocProc,    */
  662. /* then the user will be able to drag the dialog.                                    */
  663. /* Modifies global curEvent (Globals.p).                                            */
  664. /*----------*/
  665. void    MovableDialog    (ModalFilterProcPtr        filterProc,
  666.                          short                    *itemHit)
  667. {
  668. /*Need to disable all of application's menus except Cut/Copy/Paste here*/
  669.     *itemHit = 0;
  670.     if (FrontWindow () != NULL) {
  671.         sFiltered = false;
  672.         while (!sFiltered) {
  673.             *itemHit = DoModalEvent (filterProc);        /*also sets sFiltered*/
  674.         } /*while not sFiltered*/
  675.     } /*otherwise, no front window*/
  676. } /*MovableDialog*/
  677.